// pages/addProduct/messageBack/messageBac.js
const utilService = require('../../../utils/utilService.js');
const httpUtils = require('../../../utils/httpUtils.js');


Page({

  /**
   * 页面的初始数据
   */
  data: {
    goodsData:{},
    shareMsg:"",
    // remindStr:"感谢您分享了宝贝，小果冻会尽快审核哒！",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getShareMessage(8)    
    this.setData({
      goodsData: JSON.parse(options.goodsData)
    })
  },
  //获取分享信息
  getShareMessage: function (type) {
    var self = this;
    utilService.shareSettings(type,
      function (data) {
        console.log("分享数据", data)
        self.setData({
          shareMsg: data.title
        })
      },
      function (error) {

      }
    );
  },
  // /**
  // * 用户点击右上角分享
  // */
  // onShareAppMessage: function (res) {
  //   var title = this.data.shareMsg
  //   var path = "pages/home/home?userId=" + getApp().globalData.userId
  //   return {
  //     title: title,
  //     path: path,
  //     success: function (res) {
  //     },
  //     fail: function (res) {
  //     }
  //   }
  // },

  returnHome:function(e){
    wx.switchTab({
      url: '../../home/home'
    })
  },
  checkClick:function(e){
    console.log(this.data.goodsData.goodsId)
    wx.navigateTo({
      url: '../../../goods/pages/goodsDetails/goodsDetails?goods_type=' + this.data.goodsData.saleTypeId + '&goods_id=' + this.data.goodsData.goodsId,
    })

  },
  showTost: function (str) {
    wx.showToast({
      title: str,
      icon: 'succes',
      duration: 1000,
      mask: true
    })
  },
  // onShareAppMessage: function (res) {
  //   // console.log('1234456' + this.sharedData)
  //   let that = this
  //   var title = this.data.shareMsg

  //   if (res.from === 'button') {
  //     // 来自页面内转发按钮
  //     console.log(res.target)
  //   }
  //   return {
  //     // title: that.data.goodsData.sharedData.titleStr,
  //     // desc: that.data.goodsData.sharedData.describeStr,
  //     title: title,//'看看我在【趣闲】平台上发布了啥闲置物品',
  //     path: '/goods/pages/goodsDetails/goodsDetails?goods_type=' + that.data.goodsData.saleTypeId + '&goods_id=' + that.data.goodsData.goodsId + "&userId=" + getApp().globalData.userId,
  //     success: function (res) {
  //       // 转发成功
  //     },
  //     fail: function (res) {
  //       // 转发失败
  //     }
  //   }
  // },

  //点击开心果冻
  tangguoClick: function (e) {
    console.log('开心果冻');
    let videoUrl;
    videoUrl = getApp().globalData.baseUrl + '/resources/ad/happy-jelly.mp4';
    if (getApp().globalData.baseUrl.indexOf('quxian') != -1) {
      videoUrl = "http://resources.zuanliantech.com/ad/happy-jelly.mp4"
    }
    wx.navigateTo({
      url: '/pages/goodsShare/goodsShare?pageType=3&videoUrl=' + encodeURIComponent(videoUrl),
    })
  },
})